<template>
	<slot :controller="controller" :store="store" :model="model">
		<AppForm
			ref="editForm"
			v-bind="$attrs"
			:id="controlID"
			:name="model.codeName"
			:class="classNames"
			:data="store.data"
		>
			<AppAnchor
				v-if="store.anchorData.length > 0"
				:controlID="controlID"
				:anchorData="store.anchorData"
			/>
			<div class="control-content app-control-form__content">
				<AppRow :layoutOpts="{ selfLayout: 'TABLE_24COL' }">
					<AppCol
						noRoot
						:visible="store.detailModel.group1.visible"
						:layoutOpts="{
							selfLayout: 'TABLE_24COL',
							parentLayout: 'TABLE_24COL',
							colMD: 24,
						}"
					>
						<template #default="{ slotClass, slotStyle }">
							<slot
								name="group1"
								:controller="controller"
								:store="store"
								:model="model"
								:slotClass="slotClass"
								:slotStyle="slotStyle"
								:actions="{ handleComponentAction }"
							>
								<AppFormGroup
									name="group1"
									v-show="store.detailModel.group1.visible"
									:slotClass="slotClass"
									:slotStyle="slotStyle"
									:layoutOpts="{
										selfLayout: 'TABLE_24COL',
										parentLayout: 'TABLE_24COL',
										colMD: 24,
									}"
									title="单位信息"
									subCaption=""
									:enableAnchor="false"
									:showMoreItems="store.detailModel.group1.showMoreItems"
									:showMoreMode="store.detailModel.group1.showMoreMode"
									:infoGroupMode="true"
									:titleBarCloseMode="0"
									:showCaption="false"
									:uIActionGroup="store.detailModel.group1.uIActionGroup"
									@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
								>
									<AppCol
										noRoot
										:visible="store.detailModel.organization_number.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="organization_number"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="organization_number"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="机构编号"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="
														store.detailModel.organization_number.valueRule
													"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="organization_numberEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="25"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="organization_number"
																noValueShowMode="STYLE1"
																:value="store.data.organization_number"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.id.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="id"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="id"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="标识"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="store.detailModel.id.valueRule"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="idEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="25"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="id"
																noValueShowMode="STYLE1"
																:value="store.data.id"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.organization_name.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="organization_name"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="organization_name"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="名称"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="store.detailModel.organization_name.valueRule"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="organization_nameEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="25"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="organization_name"
																noValueShowMode="STYLE1"
																:value="store.data.organization_name"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.short_name.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="short_name"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="short_name"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="简称"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="store.detailModel.short_name.valueRule"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="short_nameEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="25"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="short_name"
																noValueShowMode="STYLE1"
																:value="store.data.short_name"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.sort.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="sort"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="sort"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="排序"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="store.detailModel.sort.valueRule"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="sortEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="1"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="sort"
																noValueShowMode="STYLE1"
																:value="store.data.sort"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.parent_name.visible"
										:layoutOpts="{
											parentLayout: 'TABLE_24COL',
											colLG: 8,
											colMD: 8,
										}"
									>
										<template v-slot:default="{ slotStyle, slotClass }">
											<slot
												name="parent_name"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormItem
													name="parent_name"
													:slotStyle="slotStyle"
													:slotClass="slotClass"
													label="上级名称"
													labelPos="LEFT"
													:labelWidth="130"
													:showLabel="true"
													:enableAnchor="false"
													:rules="store.detailModel.parent_name.valueRule"
													:emptyCaption="false"
												>
													<div class="form-editor-container">
														<slot
															name="parent_nameEditor"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppSpan
																:context="store.context"
																:viewParams="store.viewParams"
																:dataType="25"
																v-bind="{ editorType: 'SPAN' }"
																deMajorField=""
																editorType="SPAN"
																style=""
																name="parent_name"
																noValueShowMode="STYLE1"
																:value="store.data.parent_name"
															/>
														</slot>
													</div>
												</AppFormItem>
											</slot>
										</template>
									</AppCol>
								</AppFormGroup>
							</slot>
						</template>
					</AppCol>
					<AppCol
						noRoot
						:visible="store.detailModel.tabpanel1.visible"
						:layoutOpts="{ parentLayout: 'TABLE_24COL', colMD: 24 }"
					>
						<template v-slot:default="{ slotStyle, slotClass }">
							<slot
								name="tabpanel1"
								:controller="controller"
								:store="store"
								:model="model"
								:slotStyle="slotStyle"
								:slotClass="slotClass"
							>
								<a-tabs
									:class="{
										[slotClass ? slotClass : '']: true,
										'app-control-form__tab-panel': true,
									}"
									:style="slotStyle"
								>
									<slot
										name="tabpage1"
										:controller="controller"
										:store="store"
										:model="model"
									>
										<a-tab-pane
											forceRender
											class="app-control-form__tab-page"
											v-show="store.detailModel.tabpage1.visible"
											key="tabpage1"
										>
											<template #tab>
												<slot
													name="tabpage1Title"
													:controller="controller"
													:store="store"
													:model="model"
												>
													<AppIconText text="人员信息" />
												</slot>
											</template>
											<slot
												name="tabpage1Content"
												:controller="controller"
												:store="store"
												:model="model"
											>
												<AppFormTabPage
													:layoutOpts="{ selfLayout: 'TABLE_24COL' }"
												>
													<AppCol
														noRoot
														:visible="store.detailModel.druipart1.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colMD: 24,
														}"
													>
														<slot
															name="druipart1"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppFormDruipart
																name="druipart1"
																:paramItem="model.entityCodeName.toLowerCase()"
																:parentName="model.entityCodeName"
																:context="store.context"
																:viewParams="store.viewParams"
																:data="store.data"
																:isLoaded="store.isLoaded"
																:tempMode="0"
																viewName="sys_personOrgPersonView"
																@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
															>
															</AppFormDruipart>
														</slot>
													</AppCol>
												</AppFormTabPage>
											</slot>
										</a-tab-pane>
									</slot>
									<slot
										name="tabpage2"
										:controller="controller"
										:store="store"
										:model="model"
									>
										<a-tab-pane
											forceRender
											class="app-control-form__tab-page"
											v-show="store.detailModel.tabpage2.visible"
											key="tabpage2"
										>
											<template #tab>
												<slot
													name="tabpage2Title"
													:controller="controller"
													:store="store"
													:model="model"
												>
													<AppIconText text="部门信息" />
												</slot>
											</template>
											<slot
												name="tabpage2Content"
												:controller="controller"
												:store="store"
												:model="model"
											>
												<AppFormTabPage
													:layoutOpts="{ selfLayout: 'TABLE_24COL' }"
												>
													<AppCol
														noRoot
														:visible="store.detailModel.druipart2.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colMD: 24,
														}"
													>
														<slot
															name="druipart2"
															:controller="controller"
															:store="store"
															:model="model"
															:actions="{ handleComponentAction }"
														>
															<AppFormDruipart
																name="druipart2"
																:paramItem="model.entityCodeName.toLowerCase()"
																:parentName="model.entityCodeName"
																:context="store.context"
																:viewParams="store.viewParams"
																:data="store.data"
																:isLoaded="store.isLoaded"
																:tempMode="0"
																viewName="sys_departmentUsr02GridView"
																@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
															>
															</AppFormDruipart>
														</slot>
													</AppCol>
												</AppFormTabPage>
											</slot>
										</a-tab-pane>
									</slot>
								</a-tabs>
							</slot>
						</template>
					</AppCol>
				</AppRow>
			</div>
		</AppForm>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{spinalCase ctrl.codeName}}-form-base.vue.hbs生成

import { Ref } from 'vue';
import { AppAnchor } from '@components/common/anchor';
import { AppCol } from '@/components/common/col';
import { AppRow } from '@/components/common/row';
import {
	AppForm,
	AppFormPage,
	AppFormGroup,
	AppFormTabPage,
	AppFormItem,
	AppFormButton,
	AppFormDruipart,
	AppFormIframe,
	AppFormRaw,
	AppFormMdCtrl,
	AppFormMdCtrlRepeater,
} from '@components/widgets/form';
import {
	IEvent,
	EditFormActionType,
	IEditFormAbility,
	IEditFormStore,
	IParam,
} from '@/core';
import {
	useProps,
	useBasic,
	useAction,
	useController,
} from './usr-0301710887-form-hook';

const editForm: Ref = ref(null);

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	controlID,
	getClassNames,
	model,
	useNavParamsBind,
	useEventBind,
	handleActionClick,
	handleComponentAction,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'ctrl-action',
		name: string,
		action: EditFormActionType,
		data: IParam[]
	): void;
	(event: 'ctrl-init', name: string, data: IEditFormAbility): void;
	(event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
	return getClassNames(props);
});

//  表单控制器
const controller = useController(props, evt, { controlID, editForm });

useNavParamsBind(controller, props);

const store: IEditFormStore = controller.getStore();

const ctrlService = controller.getCtrlService();

onMounted(() => {
	controller.ctrlMounted();
});
onUnmounted(() => {
	controller.ctrlDestroy();
});
</script>
